﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Context;
using Entities;
namespace WCF_ListenMusic.Services
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "SingerService" in code, svc and config file together.
    public class SingerService : ISingerService
    {
        Context.Connect_DBDataContext context = new Context.Connect_DBDataContext();


        #region ISingerService Members

        public List<Singer> getAllSingerByContry(int countryID)
        {
            try
            {
                if (countryID <= 0)
                {
                    throw new FaultException("Country is zero or nagative");
                }
                else
                {
                    var q = from c in context.Singers
                            where c.CountryID.Equals(countryID)
                            select c;
                    return q.ToList();
                }
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
        #endregion


        public Singer getSinger_bySingerID(int singerid)
        {
            try
            {
                if (singerid <= 0)
                {
                    throw new FaultException("SingerID is zero or nagative");
                }
                else
                {
                    var q = from c in context.Singers
                            where c.SingerID.Equals(singerid)
                            select c;
                    return q.Single();
                }
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }

        #region ISingerService Members


        public List<Singer> getSingerByName(string singerName)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
